package com.goodving.guli.activity;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.ViewConfiguration;

import com.goodving.guli.utility.Constants;

/**
 * Created by john on 2015/11/26.
 */
public class fh {
    private static final String f10220a = "status_bar_height";
    private static final String f10221b = "navigation_bar_height";
    private static final String f10222c = "navigation_bar_height_landscape";
    private static final String f10223d = "navigation_bar_width";
    private static final String f10224e = "config_showNavigationBar";
    private final boolean f10225f;
    private final boolean f10226g;
    private final int f10227h;
    private final int f10228i;
    private final boolean f10229j;
    private final int f10230k;
    private final int f10231l;
    private final boolean f10232m;
    private final float f10233n;

    public fh(Activity activity, boolean z, boolean z2) {
        boolean z3 = true;
        Resources resources = activity.getResources();
        this.f10232m = resources.getConfiguration().orientation == 1;
        this.f10233n = m14868a(activity);
        this.f10227h = m14870a(resources, f10220a);
        this.f10228i = m14869a((Context) activity);
        this.f10230k = m14871b(activity);
        this.f10231l = m14872c(activity);
        if (this.f10230k <= 0) {
            z3 = false;
        }
        this.f10229j = z3;
        this.f10225f = z;
        this.f10226g = z2;
    }

    @SuppressLint({"NewApi"})
    private float m14868a(Activity activity) {
        DisplayMetrics displayMetrics = new DisplayMetrics();
        if (Build.VERSION.SDK_INT >= 16) {
            activity.getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics);
        } else {
            activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        }
        return Math.min(((float) displayMetrics.widthPixels) / displayMetrics.density, ((float) displayMetrics.heightPixels) / displayMetrics.density);
    }

    @TargetApi(14)
    private int m14869a(Context context) {
        if (Build.VERSION.SDK_INT < 14) {
            return 0;
        }
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(16843499, typedValue, true);
        return context.getResources().getDimensionPixelSize(typedValue.resourceId);
    }

    private int m14870a(Resources resources, String str) {
        int identifier = resources.getIdentifier(str, "dimen", "android");
        return identifier > 0 ? resources.getDimensionPixelSize(identifier) : 0;
    }

    @TargetApi(14)
    private int m14871b(Context context) {
        Resources resources = context.getResources();
        if (Build.VERSION.SDK_INT < 14 || !m14873d(context)) {
            return 0;
        }
        return m14870a(resources, this.f10232m ? f10221b : f10222c);
    }

    @TargetApi(14)
    private int m14872c(Context context) {
        return (Build.VERSION.SDK_INT < 14 || !m14873d(context)) ? 0 : m14870a(context.getResources(), f10223d);
    }

    @TargetApi(14)
    private boolean m14873d(Context context) {
        boolean z = true;
        Resources resources = context.getResources();
        int identifier = resources.getIdentifier(f10224e, "bool", "android");
        if (identifier != 0) {
            return Constants.VIA_TO_TYPE_QQ_GROUP.equals(ff.f10212b) ? false : Constants.VIA_RESULT_SUCCESS.equals(ff.f10212b) ? true : resources.getBoolean(identifier);
        } else {
            if (ViewConfiguration.get(context).hasPermanentMenuKey()) {
                z = false;
            }
            return z;
        }
    }

    public int m14874a(boolean z) {
        int i = 0;
        int i2 = this.f10225f ? this.f10227h : 0;
        if (z) {
            i = this.f10228i;
        }
        return i + i2;
    }

    public boolean m14875a() {
        return this.f10233n >= 600.0f || this.f10232m;
    }

    public int m14876b() {
        return this.f10227h;
    }

    public int m14877c() {
        return this.f10228i;
    }

    public boolean m14878d() {
        return this.f10229j;
    }

    public int m14879e() {
        return this.f10230k;
    }

    public int m14880f() {
        return this.f10231l;
    }

    public int m14881g() {
        return (this.f10226g && m14875a()) ? this.f10230k : 0;
    }

    public int m14882h() {
        return (!this.f10226g || m14875a()) ? 0 : this.f10231l;
    }
}